<?php
namespace app\api\controller;
use x\my\Captcha;
use x\Xbase;
use Endroid\QrCode\QrCode;
class Com extends Xbase{

    //二维码
    public function qrcode(){
        $txt = $this->get('txt','abcdd');
        $txt = urldecode($txt);
        $qrCode = new QrCode($txt);
        header('Content-Type: '.$qrCode->getContentType());
        echo $qrCode->writeString();
        exit;
    }

    //验证码
    public function captcha(){
        $token = $this->get('token');
        cookie('captcha_token',$token);
        return Captcha::generate($token);
    }
}
